﻿using System;
using System.Net;
using System.IO;

namespace Smugmug
{
    internal class UploadContext
    {
        public HttpWebRequest Request { get; private set; }
        public Stream PhotoStream { get; set; }
        public Stream RequestStream { get; set; }
        public long CurrentPosition { get; set; }
        public int ChunkSize { get; set; }

        public UploadContext()
        {
            Request = (HttpWebRequest)HttpWebRequest.Create("http://upload.smugmug.com/photos/xmlrawadd.mg");
            Request.Method = "POST";
            Request.Timeout = System.Threading.Timeout.Infinite;

            PhotoStream = null;
            RequestStream = null;
            CurrentPosition = 0;
            ChunkSize = 0;
        }

        public int PercentComplete
        {
            get
            {
                if (PhotoStream == null || PhotoStream.Length == 0)
                    return 0;
                return Convert.ToInt32((CurrentPosition * 100) / PhotoStream.Length);
            }
        }
    }
}